<template>
  <view class="tabbar">
    <view 
      v-for="(item, index) in tabs" 
      :key="index"
      class="tab-item"
      :class="{ active: current === index }"
      @click="$emit('change', index)"
    >
      <text class="tab-icon">{{ item.icon }}</text>
      <text class="tab-text">{{ item.text }}</text>
    </view>
  </view>
</template>

<script setup>
defineEmits(['change'])
defineProps({
  current: {
    type: Number,
    default: 0
  }
})

const tabs = [
  { icon: '📚', text: '课程' },
  { icon: '🎥', text: '视频' },
  { icon: '🛍️', text: '商城' },
  { icon: '👤', text: '我的' }
]
</script>

<style scoped>
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  border-top: 1px solid #e5e5e5;
  padding: 10rpx 0 20rpx;
  z-index: 999;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10rpx;
}
.tab-icon {
  font-size: 44rpx;
  margin-bottom: 8rpx;
}
.tab-text {
  font-size: 22rpx;
  color: #666;
}
.tab-item.active .tab-text {
  color: #ff6b35;
}
</style>
